import java.util.Scanner;

/**
 * DP34 【模板】前缀和
 */
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), m = in.nextInt();
        int[] arr = new int[n + 1];

        for(int i = 1; i < n + 1; i++) {
            arr[i] = in.nextInt();
        }

        // 动态规划
        long[] dp = new long[n + 1];
        for(int i = 1; i < n + 1; i++) {
            dp[i] = dp[i - 1] + arr[i];
        }

        while(m > 0) {
            int l = in.nextInt(), r = in.nextInt();
            long tmp = dp[r] - dp[l - 1];
            System.out.println(tmp);
            m--;
        }
    }
}